<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>添加闸机</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../js/layui/css/layui.css" media="all">
    <style>
        .layui-form-label.layui-required:after{
            content:"*";
            color:red;
            position: absolute;
            top:5px;
            left:30px;
        }
    </style>
</head>
<body>
<div style="width:80%;height:765px;margin:15px auto;overflow:auto;" id="aaa">
    <form class="layui-form" action="" id="update_staff">
        <input type="hidden" class="input-text" id="id" name="gateId">
        <div class="layui-form-item">
            <label class="layui-form-label">设备编号</label>
            <div class="layui-input-block">
                <input type="text" name="sno" required lay-verify="required" placeholder="请输入设备编号" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">设备名称</label>
            <div class="layui-input-block">
                <input type="text" name="deviceName" required lay-verify="required" placeholder="请输入设备名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">设备类型</label>
            <div class="layui-input-block">
                <input type="text" name="deviceType" required lay-verify="required" placeholder="请输入设备类型，如：微耕门禁设备" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">设备位置</label>
            <div class="layui-input-block">
                <input type="text" name="gateLoc" placeholder="请输入设备位置" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item" style="margin-top: 20px">
            <div class="layui-input-block">
                <button class="layui-btn" id="addGate" lay-submit lay-filter="addGate">立即提交</button>
                <button type="reset" id="reset" class="layui-btn layui-btn-primary" lay-filter="resetData">重置</button>
            </div>
        </div>
    </form>
</div>
<script src="../../js/layui/layui.js"></script>
<script src="../../js/layui/layui.all.js"></script>
<script src="../../js/token.js"></script>
<script src="../../js/config.js"></script>

<script>

    layui.use(['form' , 'jquery' , 'upload'], function(){
        var form = layui.form;
        var $ = layui.jquery;

        //修改操作
        form.on('submit(addGate)',function(data){
            $.ajax({
                url:HOST+"gate/addGate"
                ,type:"POST"
                ,contentType: 'application/json'
                ,data:JSON.stringify(data.field)
                ,success:function (data) {
                     if(data.code==200){
                         layer.close(layer.index);
                         layer.msg('添加成功');
                         setTimeout(function(){
                             window.location.reload();
                         },3000);
                    }else{
                        layer.msg(data.msg);
                    }
                }
                ,error:function () {
                    console.log("ajax error");
                }
            });
            return false;
        });

    });
</script>

</body>
</html>